/*
 * addon.h
 *
 *  Created on: 2010-1-7
 *      Author: gavinkwoe
 */

#ifndef ADDON_SYSTEM_H_
#define ADDON_SYSTEM_H_

#include "addon_features.h"
#include "addon_std.h"
#include "addon_objbase.h"

/*************************************************************************
* TYPE
*************************************************************************/

typedef void *	( ADDON_PROC addon_alloc_fptr_t )( void * para );

/*************************************************************************
* INTERFACE
*************************************************************************/

ADDON_INTERFACE_( IAddonSystem, 1, IObject )
{
	__INHERIT_FROM( IObject )

	ADDON_METHOD( Register )		( ADDON_REF(IObject) thiz, IN addon_guid_t guid, IN addon_alloc_fptr_t alloc );
	ADDON_METHOD( Unregister )		( ADDON_REF(IObject) thiz, IN addon_guid_t guid );
	ADDON_METHOD( CreateObject )	( ADDON_REF(IObject) thiz, IN addon_guid_t guid, OUT void ** ppobj );
	
	ADDON_METHOD( SetHomePath )		( ADDON_REF(IObject) thiz, IN unsigned short * path );
	
	ADDON_METHOD( Load )			( ADDON_REF(IObject) thiz, IN unsigned short * name, OUT void ** ppobj, OUT unsigned long * reason );
	ADDON_METHOD( Unload )			( ADDON_REF(IObject) thiz, IN ADDON_REF(IObject) addon );

	ADDON_METHOD( Support )			( ADDON_REF(IObject) thiz, IN unsigned short * name, OUT unsigned long * pret );
	ADDON_METHOD( Recycle )			( ADDON_REF(IObject) thiz, IN unsigned long bytes_need );
};

/*************************************************************************
* DECLARATION
*************************************************************************/

#if defined(__cplusplus)
extern "C" {
#endif	// #if defined(__cplusplus)

ADDON_IMPORT ADDON_REF(IObject)	addon_create_system( void * reserved );

#if defined(__cplusplus)
}
#endif	// #if defined(__cplusplus)

/*************************************************************************
* MACRO
*************************************************************************/

#define IAddonSystem_VTBL( p )					ADDON_GET_VTBL_(p, IAddonSystem)
#define IAddonSystem_CALL( p, a )				IAddonSystem_VTBL(p)->a
#define IAddonSystem_Register( p, a, b )		IAddonSystem_CALL( p, Register )( p, a, b )
#define IAddonSystem_Unregister( p, a )			IAddonSystem_CALL( p, Unregister )( p, a )
#define IAddonSystem_CreateObject( p, a, b )	IAddonSystem_CALL( p, CreateObject )( p, a, b )
#define IAddonSystem_SetHomePath( p, a )		IAddonSystem_CALL( p, SetHomePath )( p, a )
#define IAddonSystem_Load( p, a, b, c )			IAddonSystem_CALL( p, Load )( p, a, b, c )
#define IAddonSystem_Unload( p, a )				IAddonSystem_CALL( p, Unload )( p, a )
#define IAddonSystem_Support( p, a, b )			IAddonSystem_CALL( p, Support )( p, a, b )
#define IAddonSystem_Recycle( p, a )			IAddonSystem_CALL( p, Recycle )( p, a )

#endif /* ADDON_SYSTEM_H_ */
